/*
 
 HLPViewController.m
 
 Coding for HLPViewController.m has used reference from the following link
 http://lievendekeyser.net/index.php?module=messagebox&action=message&msg_id=1351
 
 Author: Steven He <cha42@sfu.ca>
 
 Copyright (C) 2010 Green-Power
 
 URL: http://code.google.com/p/green-power
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 $Id$
 */

#import "HLPViewController.h"
#import "HLPView.h"

@implementation HLPViewController

@synthesize nextViewController;

- (id)initWithImages:(NSArray *)images; {
  if (self = [super initWithNibName:nil bundle:nil]) {
    self.view = [[HLPView alloc] initWithImages:images];
	}
	
	return self;
}

- (void)setNextViewController:(UIViewController *)newNextViewController {
  if(nextViewController) [nextViewController release];
  
  nextViewController=[newNextViewController retain];
  
  // Setup a button in the navigation bar to go to the next view controller,
  // if it exists
  if(nextViewController) {
    UIBarButtonItem *nextViewButton=[[UIBarButtonItem alloc] initWithTitle:@"Continue"
                                                                     style:UIBarButtonItemStyleDone
                                                                    target:self 
                                                                    action:@selector(showNextViewController)];
    self.navigationItem.rightBarButtonItem=nextViewButton;
    [nextViewButton release];
  } else {
    self.navigationItem.rightBarButtonItem=nil;
  }
}

- (void)showNextViewController {
  [self.navigationController pushViewController:nextViewController
                                       animated:YES];
}

- (void)didReceiveMemoryWarning {
  // Releases the view if it doesn't have a superview.
  [super didReceiveMemoryWarning];
	
  // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
  // Release any retained subviews of the main view.
  // e.g. self.myOutlet = nil;
}


- (void)dealloc {
  [super dealloc];
}

- (IBAction)toggleNavigationBar:(id)sender {
  //Check the current state of the navigation bar...
  BOOL navBarState = [self.navigationController isNavigationBarHidden];
  //Set the navigationBarHidden to the opposite of the current state.
  [self.navigationController setNavigationBarHidden:!navBarState animated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  [self.navigationController setNavigationBarHidden:NO animated:YES];
  self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
  [self setTitle:@"Help"];

} 


- (void)viewWillDisappear:(BOOL)animated {
  [super viewDidDisappear:animated];
  self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  [self.navigationController setNavigationBarHidden:YES animated:YES];
	
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  // Return YES for supported orientations
  return interfaceOrientation=UIInterfaceOrientationLandscapeLeft;
}

@end